package com.bbg.amyam.web.util;

import java.security.MessageDigest;

public class StringEncryptor {

		

	    /**
	     * @param args the command line arguments
	     */
	    public static void main(String[] args) throws Exception
	    {
	        String[] passwds = {"azer89","wifecao1","1","2","3"};
	        for (String password:passwds){
	        	String r=encrypte(password);
	        System.out.println(password+"\n"+encrypte(password)+"\n"+r+"\n"+r.length());
	        }
	    }

	    public static String encrypte (String plainString) throws Exception
	    {
	        MessageDigest m = MessageDigest.getInstance("MD5");
	        m.update(plainString.getBytes("UTF8"));
	        byte s[] = m.digest();
	        String result = "";
	        for (int i = 0; i < s.length; i++) {
	          result += Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6);
	        }

	        return result;
	    }

	
}
